//
// Copyright (c) 2024 BPer
//
#ifndef BPerThread2_H__
#define BPerThread2_H__

#include <bperutil/sys/BPerThread.h>
#include <bperutil/BPerType.h>

#define bPer_stop_thread(x) if(x){while(x->m_isStart) bPer_usleep(1000);}
#define bPer_stop(x) if(x&&x->m_isStart){x->stop();}
class BPerThread {
public:
	BPerThread();
	virtual ~BPerThread();

	int32_t start();
	void* join();
	int32_t detach();
	int32_t equals(BPerThread *t);
	void exitThread(void *value_ptr);
	//int32_t cancel();
	bPer_thread_t getThread();
	virtual void stop()=0;
protected:
	virtual void run() = 0;

private:
	static void* go(void *obj);
	bPer_thread_t m_thread;

};

#endif
